package android.pot.com.smartcar.ui.home;

import android.content.Context;
import android.graphics.Point;
import android.pot.com.smartcar.util.ImageLoadUtils;
import android.view.WindowManager;
import android.widget.ImageView;

import cn.bingoogolapple.bgabanner.BGABanner;

/**
 * Created by zhaoshilu on 2017/8/29.
 */

public class BGABannerssAdapter implements BGABanner.Adapter<ImageView, String> {
    private Context context;

    int screenWidth;

    public BGABannerssAdapter(Context context) {
        this.context = context;
        this.screenWidth = getScreenWidth();
    }

    private int getScreenWidth(){
        //获取屏幕的宽度
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Point size = new Point();
        wm.getDefaultDisplay().getSize(size);
        screenWidth = size.x;
        System.out.println("screenWidth:" + screenWidth);
        return screenWidth;
    }
    @Override
    public void fillBannerItem(final BGABanner banner, final ImageView itemView, String model, int position) {
         itemView.setScaleType(ImageView.ScaleType.FIT_XY);
         ImageLoadUtils.INSTANCE.loadImageView(itemView, model);


    }


}

